package view;

import java.awt.Dimension;

import javax.swing.JPanel;
import javax.swing.JScrollPane;

import model.State;


/**
 * Displays the role specific information in the main GUI view.
 * @author Sarah George
 * @version Autumn 2012
 */
@SuppressWarnings("serial")
public class RolePanel  extends JPanel {
	
	/**
	 * Teh current state of the system.
	 */
	private State my_state;
	
	/**
	 * Constructor for a role panel.
	 * @param the_state the current state of the system.
	 */
	public RolePanel(State the_state) {
		super();
		setPreferredSize(new Dimension(1024, 300));
		my_state = the_state;
		setup();
	}

	/**
	 * Method to setup the role panel depending upon which role is active in the state.
	 */
	public void setup() {
		switch(my_state.getRole()) {
		case AUTHOR:
			authorSetup();
			break;
		case PC:
			pcSetup();
			break;
		case REVIEWER:
			reviewerSetup();
			break;
		case SPC:
			spcSetup();
			break;
		default: //Author
			unassignedSetup();
			break; 
		}
	}
	
	/**
	 * Method to setup an author panel. 
	 */
	public void authorSetup() {
		AuthorPanel author = new AuthorPanel(my_state);
		this.add(author);
	}
	
	/**
	 * Method to setup a pc panel.
	 */
	public void pcSetup() {
		PCPanel pcPanel = new PCPanel(my_state);
		pcPanel.setMaximumSize(new Dimension(2000,800));
		pcPanel.setAutoscrolls(true);
		JScrollPane scrollPane = new JScrollPane(pcPanel);
		scrollPane.setPreferredSize(new Dimension(1024, 300));
		
		this.add(scrollPane);
	}
	
	/**
	 * Method to setup a reviewer panel.
	 */
	public void reviewerSetup() {
		ReviewerPanel rp = new ReviewerPanel(my_state);
		this.add(rp);
	}
	
	/**
	 * Method to setup and spc panel.
	 */
	public void spcSetup() {
		SPCPanel sp = new SPCPanel(my_state);
		sp.setMaximumSize(new Dimension(2000,800));
		sp.setAutoscrolls(true);
		JScrollPane scrollPane = new JScrollPane(sp);
		scrollPane.setPreferredSize(new Dimension(1024, 300));
		
		this.add(scrollPane);
	}
	
	/**
	 * Method to set up an unassigned panel.
	 */
	public void unassignedSetup() {
		UnAssignedPanel user = new UnAssignedPanel(my_state);
		this.add(user);
	}	
}//End class Role Panel.